package com.yunhe.dao;


import com.yunhe.pojo.Department;
import org.springframework.stereotype.Repository;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;


@Repository
// 部门dao
public class DepartmentDao {

    // 模拟数据库中的数据
    private static Map<Integer, Department> departments;

    static {
        // 创建一个部门表
        departments = new HashMap<>();

        departments.put(101,new Department(101,"市场部"));
        departments.put(102,new Department(102,"科研部"));
        departments.put(103,new Department(103,"后勤部"));
        departments.put(104,new Department(104,"销售部"));
        departments.put(105,new Department(105,"小卖部"));
    }

    // 获得所有部门信息
    public Collection<Department> getDepartments(){
        return departments.values();
    }

    // 通过id获取部门的信息
    public Department getDepartmentById(Integer id){
        return departments.get(id);
    }

}
